package com.ceair.flight.refund.util;

/**
 * 接口返回的信息
 *
 * @Author ZhuBeiBei
 * @Date: Created in 2019/1/14 14:27
 */
public enum ReturnMsg {

    SUCCESS("0", "成功"),
    ERROR("1", "接口处理失败,请稍后重试"),
    SERVICE_ERROR_208("208", "获取运价渠道号失败"),
    SERVICE_ERROR_249("249", "通过机场获取国家代号失败"),
    SERVICE_ERROR_250("250", "判断航段是否属于北美航段失败"),
    SERVICE_ERROR_315("315", "机场【%s】的详细信息未找到"),
    SERVICE_ERROR_401("401", "获取IATA信息失败")
    ;

    /**
     * 接口返回结果码
     */
    private String code;

    /**
     * 接口返回描述信息
     */
    private String msg;

    ReturnMsg(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 根据code查询msg
     *
     * @param code
     * @return
     */
    public static String getMessage(String code){
        for (ReturnMsg value : values()) {
            if (value.code.equals(code)) {
                return value.getMsg();
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }}
